package com.huawei.spare.part.replace.models;

import java.io.Serializable;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class UpgradeTask implements Serializable {

  StringProperty step;                        // 步骤
  StringProperty operation;                   //  操作
  DoubleProperty progress;                    // 进度
  ObjectProperty<PerformTask.Status> status;           // 状态

  public UpgradeTask() {
    this.step = new SimpleStringProperty();
    this.operation = new SimpleStringProperty();
    this.progress = new SimpleDoubleProperty();
    this.status = new SimpleObjectProperty<>();
  }

  public UpgradeTask(String step, String operation, double progress, Status status) {
    this.step = new SimpleStringProperty(step);
    this.operation = new SimpleStringProperty(operation);
    this.progress = new SimpleDoubleProperty(progress);
    this.status = new SimpleObjectProperty(status);
  }

  public StringProperty stepProperty() {
    return step;
  }

  public StringProperty operationProperty() {
    return operation;
  }

  public DoubleProperty progressProperty() {
    return progress;
  }

  public ObjectProperty statusProperty() {
    return status;
  }

  public enum Status {
    Pending("upgrade.task.status.pending"),
    Waiting("upgrade.task.status.waiting"),
    Processing("upgrade.task.status.processing"),
    Completed("upgrade.task.status.completed"),
    Failed("upgrade.task.status.failed");

    String display;

    Status(String display) {
      this.display = display;
    }

    public String getDisplay() {
      return display;
    }

  }
}
